package com.easyapi.service.sync;

import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.util.concurrent.CompletableFuture;
import java.util.function.Supplier;

/**
 * @author javadadi
 * @param <T>
 */
@Service
public class AsyncMethodHandler<T> {
    @Async
    public CompletableFuture<T> async(Supplier<T> supplier) {
        // 异步执行任务，并返回 CompletableFuture
        return CompletableFuture.supplyAsync(supplier);
    }
}
